package thread;

import java.util.Scanner;

public class Demo24 {
    public static void main(String[] args) {
        Object locker1 = new Object();
        Object locker2 = new Object();

        Thread t1 = new Thread(() -> {
            try{
                Thread.sleep(3000);
                System.out.println("wait之前");
                synchronized (locker1) {
                    locker1.wait();
                }
            }catch (InterruptedException e){
                throw new RuntimeException();
            }
        });

        Thread t2 = new Thread(() -> {
            Scanner in =new Scanner(System.in);
            System.out.println("任意输入唤醒t1");
            in.next();
            synchronized (locker1){
                locker1.notify();
            }
        });

        t1.start();
        t2.start();
    }
}
